<html>
<head><meta charset="utf-8"><title>GeneratorWitness type · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html">GeneratorWitness type</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="238861336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/GeneratorWitness%20type/near/238861336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html#238861336">(May 15 2021 at 02:46)</a>:</h4>
<p>What is a <code>ty::GeneratorWitness</code>? To what extent are variables of this type accessible from surface rust? I'm not really sure where to read more about the encoding of generators.</p>



<a name="238861505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/GeneratorWitness%20type/near/238861505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html#238861505">(May 15 2021 at 02:49)</a>:</h4>
<p>it contains all types that may be stored in the interior, as far as type check is concerned</p>



<a name="238861562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/GeneratorWitness%20type/near/238861562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html#238861562">(May 15 2021 at 02:50)</a>:</h4>
<p>the type itself is only used by <code>ty::Generator</code> and is not available in surface Rust AFAIK</p>



<a name="238861585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/GeneratorWitness%20type/near/238861585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html#238861585">(May 15 2021 at 02:50)</a>:</h4>
<p>as for why this list of types isn't stored in the <code>ty::Generator</code> itself, I'm not sure</p>



<a name="238861590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/GeneratorWitness%20type/near/238861590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html#238861590">(May 15 2021 at 02:50)</a>:</h4>
<p>how is this different from closure types, which don't need such a thing?</p>



<a name="238861611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/GeneratorWitness%20type/near/238861611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html#238861611">(May 15 2021 at 02:51)</a>:</h4>
<p>maybe this has to do with values live across an await point</p>



<a name="238861625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/GeneratorWitness%20type/near/238861625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html#238861625">(May 15 2021 at 02:52)</a>:</h4>
<p>yes, that's the "interior"</p>



<a name="238862782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/GeneratorWitness%20type/near/238862782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html#238862782">(May 15 2021 at 03:09)</a>:</h4>
<p>Symbol mangling a <code>GeneratorWitness</code> throws a <code>bug!</code> so I guess they are desugared somewhere before codegen?</p>



<a name="238866170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/GeneratorWitness%20type/near/238866170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html#238866170">(May 15 2021 at 04:07)</a>:</h4>
<p>A <code>GeneratorWitness</code> should never show up outside of a <code>Generator</code></p>



<a name="238866216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/GeneratorWitness%20type/near/238866216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/GeneratorWitness.20type.html#238866216">(May 15 2021 at 04:08)</a>:</h4>
<p>I'm not sure exactly how symbol mangling for a generator works, but it takes care of any logic needed for the witness types</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>